package com.ruoyi.web.controller.mall;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallOrderDetail;
import com.ruoyi.mall.service.MallOrderDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单详情Controller
 *
 * @author ruoyi
 * @date 2024-01-11
 */
@Api(tags = "订单详情")
@RestController
@RequestMapping("/mall/order/detail")
public class MallOrderDetailController extends BaseController {
    @Autowired
    private MallOrderDetailService mallOrderDetailService;

    /**
     * 查询订单详情列表
     */
    @ApiOperation("查询订单详情列表")
    @PreAuthorize("@ss.hasPermi('system:detail:list')")
    @PostMapping("/list")
    public TableDataInfo list(MallOrderDetail mallOrderDetail) {
        startPage();
        List<MallOrderDetail> list = mallOrderDetailService.selectMallOrderDetailList(mallOrderDetail);
        return getDataTable(list);
    }

    /**
     * 获取订单详情详细信息
     */
    @ApiOperation("获取订单详情详细信息")
    @PreAuthorize("@ss.hasPermi('system:detail:query')")
    @PostMapping(value = "getInfo/{orderDetailId}")
    public AjaxResult getInfo(@PathVariable("orderDetailId") Long orderDetailId) {
        return success(mallOrderDetailService.selectMallOrderDetailByOrderDetailId(orderDetailId));
    }

    /**
     * 修改订单
     */
    @ApiOperation("修改订单")
    @PreAuthorize("@ss.hasPermi('system:order:update')")
    @Log(title = "订单", businessType = BusinessType.UPDATE)
    @PostMapping("update")
    public AjaxResult update(@RequestBody MallOrderDetail mallOrderDetail) {
        return toAjax(mallOrderDetailService.updateMallOrderDetail(mallOrderDetail));
    }
}
